<style>
  .store-area-list li{margin-bottom: 10px;}
</style>
<form method="post" action="<{link app=b2c ctl=admin_goods_tip act=save}>" class="tableform" id="tip_edit">
    <{input type='hidden' name='tip_id' value=$tip.tip_id}>
  <table>
    <tbody>
      <tr>
          <th><{t}>发货仓名称<{/t}></th>
        <td colspan="2"><{input type="text" required="true" name="tip_name" id="" size="30" value=$tip.tip_name }></td>
      </tr>
      
      <tr>
          <th><{t}>配送方式<{/t}></th>
        <td colspan="2">
        <{foreach from=$dlytype item=item key=key}>
            <input type="checkbox" name="dt_ids[]" value="<{$item.dt_id}>" <{if isset($tip.dt_id_arr[$item.dt_id]) }>checked="checked"<{/if}> /><{$item.dt_name}>
        <{/foreach}>
        </td>
      </tr>
      <tr>
          <th><{t}>支付方式<{/t}></th>
        <td colspan="2">
        <{foreach from=$payments item=item key=key}>
            <input type="checkbox" name="payment_app_ids[]" value="<{$item.app_id}>" <{if isset($tip.payment_app_id_arr[$item.app_id]) }>checked="checked"<{/if}> /><{$item.app_name}>
        <{/foreach}>
        
        </td>
      </tr>
      <tr>
          <th><{t}>需身份证<{/t}></th>
        <td colspan="2">
  
            <select name="need_idcard" id="need_idcard">
            	<option value="false" <{if $tip.need_idcard=='false'}> selected="selected"<{/if}>>否</option>
                <option value="true" <{if $tip.need_idcard=='true'}> selected="selected"<{/if}>>是</option>
            </select>

        
        </td>
      </tr>
      
      <tr>
          <th><{t}>单笔订单限额<{/t}></th>
        <td colspan="2">
        <{input type="number" required="true" name="amount_max" id="amount_max" size="30" value=$tip.amount_max }>
        <span class="notice-inline">0表示不限制，该发货仓单笔订单允许的最大金额</span>
        
        </td>
      </tr>
      
      <tr>
          <th><{t}>排序<{/t}></th>
        <td colspan="2"><{input type="number" name="ordernum" id="" size="2" value=$tip.ordernum|default:50}><span class="notice-inline">数字越小越靠前</span></td>
      </tr>
      <tr>
          <th></th>
        <td>
          <ul class="store-area-list" id="tip_area">
              <li class="title"><{t}>提示内容<{/t}></li>
            <{foreach from=$tip.values item=item key=key name=name}>
            <li class="item">
            <!-- 必选项 vtype值为required -->
              <{input type="text" vtype="" name="values[{$key}]" id="" maxlength="100" value=$item size="60" pattern="((?!#\!\!#).)*" }>
              <{if $smarty.foreach.name.iteration>1}>
              <a href="javascript:void(0);" class="del">删除</a>
              <{/if}>

            </li>
            <{/foreach}>
          </ul>
          <div><{button class="btn" label="添加提示文字" icon="add_icon.gif" id="add_tip"}></div>
        </td>
        <td>
          <h5>说明：</h5>
          <p>
            建议提示文字在16字以内
          </p>
        </td>
      </tr>
      <tr>
        <th></th>
        <td><{button class="btn btn-primary" type="submit" label="保存"}></td>
      </tr>
    </tbody>
  </table>
</form>
<script type="text/javascript">
(function(){
    $('tip_edit').getElements('.del').addEvent('click', function(){
      this.getParent('.item').destroy();
    });

  var id = 1;
  function tpl(id) {
      var tpl = '';
      tpl+='<{input type="text" vtype="required" name="values[new_' + id + ']" id="" maxlength="100" size="60" pattern="((?!#\!\!#).)*" }> <a href="javascript:void(0);" class="del">删除</a>';
      return tpl;
  }
  $('add_tip').addEvent('click', function(){
      var el = new Element('li.item', {html: tpl(id++)}).inject($('tip_area'));
      el.getElement('.del').addEvent('click', function(){
          this.getParent('.item').destroy();
      });
  });

  $('tip_edit').store('target', {
    onComplete: function(rs){
        rs = JSON.decode(rs);
        if(rs.success)
        $('tip_edit').getParent('.dialog').retrieve('instance').close();
    }
  });

})()
</script>
